package com.codedancer.campus.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.codedancer.campus.common.core.BaseMapper;
import com.codedancer.campus.po.DynamicKudos;

public interface DynamicKudosMapper extends BaseMapper<DynamicKudos> {

    /**
     * 删除点赞记录
     *
     * @param uuid
     * @param currentLoginUuid
     */
    default void deleteByDynamicUuidAndUserUuid(String uuid, String currentLoginUuid) {
        LambdaQueryWrapper<DynamicKudos> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(DynamicKudos::getDynamicUuid, uuid);
        lambdaQueryWrapper.eq(DynamicKudos::getKudosUserUuid, currentLoginUuid);
        delete(lambdaQueryWrapper);
    }

    /**
     * 根据动态uuid和用户uuid判断是否存在点赞记录
     *
     * @param uuid
     * @param currentLoginUuid
     * @return
     */
    default Boolean isExistsByDynamicUuidAndUserUuid(String uuid, String currentLoginUuid) {
        LambdaQueryWrapper<DynamicKudos> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(DynamicKudos::getDynamicUuid, uuid);
        lambdaQueryWrapper.eq(DynamicKudos::getKudosUserUuid, currentLoginUuid);
        return selectCount(lambdaQueryWrapper) > 0;
    }
}
